<%@page contentType="text/html" pageEncoding="UTF-8" import="org.bsscheduler.*"%>
<jsp:useBean id="user" class="org.bsscheduler.User" scope="session" />

<%-- if not logged in, go to login page --%>
<% if (!user.getLoggedIn()) {%>
<jsp:forward page="index.jsp" />
<% }%>

<%

        String cancel = request.getParameter("cancel");
        String confirm = request.getParameter("confirm");
        String decline = request.getParameter("decline");
        String eventUUID = request.getParameter("uuid");
        Event e = user.events.getEvent(eventUUID);
        if (cancel != null) {
            if (e != null && e.getCreator().equals(user.getEmail())) {
                user.events.cancelEvent(e);
            }
        } else if (confirm != null) {
            if (e.hasParticipant(user.getEmail())) {
                user.events.updateEventStatus(e, Event.CONFIRMED);
            }
        } else if (decline != null) {
            if (e.hasParticipant(user.getEmail())) {
                user.events.updateEventStatus(e, Event.DECLINED);
            }
        }


%>
<jsp:forward page="main.jsp" />
